﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using Husb.Data;

using CentralOffice.Admin.Data;
using CentralOffice.Admin.DataAccess;
using StepTable = CentralOffice.Admin.Data.ApprovalStepDataSet.ApprovalStepDataTable;
using StepRow = CentralOffice.Admin.Data.ApprovalStepDataSet.ApprovalStepRow;

namespace CentralOffice.Admin.BusinessActions
{
    public class ApprovalStep : DataAccessManager<ApprovalStepDataSet, StepTable, StepRow, ApprovalStepAdapter>
    {
        /// <summary>
        /// 获取某个固定审批流程的各个审批步骤。注意审批步骤已在存储过程中排序，本方法内并没有排序逻辑。
        /// </summary>
        /// <param name="processId"></param>
        /// <returns></returns>
        public static StepTable GetStepByProcessId(Guid processId)
        {
            //ApprovalStepAdapter adapter = new ApprovalStepAdapter();
            //return adapter.GetStepByProcessId(processId);

            StepTable steps = new StepTable();
            StepTable s = GetAll();
            foreach (StepRow row in s.Rows)
            {
                if (row.ApprovalProcessId == processId && !row.IsDeleted && row.IsActive)
                {
                    steps.ImportRow(row);
                }
            }

            return steps;
        }
    }
}
